# CONTAINER_START_PATH is passed as an env var when the container is created it is passed to the current user via the root environment (see sudoers)

if [ -z "$CONTAINER_START_PATH" ]; then
    echo "Using default start path"
    export CONTAINER_START_PATH="/root"
fi  

if [ -z "$USER" ]; then
    export USER=$(id -nu $UID)
fi

if [ -z "$HOME" ]; then
    export HOME="/root"
fi

echo "HOME=$HOME, USER=$USER, UID=$UID"
echo "CONTAINER_START_PATH: $CONTAINER_START_PATH"
cd "$CONTAINER_START_PATH"
source $HOME/.bashrc
source /root/nvm_setup.sh

# allow writing of the CARGO_HOME dir which is owned
# by group 'rust'
# when installing rust crates using cargo keep files
# group writeable
umask 002
source $CARGO_HOME/env
